#ifndef UUID_E6889254702D4480D8712EB9005A536B
#define UUID_E6889254702D4480D8712EB9005A536B

#include "packet.hpp"
#include "packet_model.hpp"

namespace Psync5
{

struct PacketDataReader
{
	PacketDataReader(Packet& srcPacketInit, uint32_t channelCountInit)
	: srcPacket(srcPacketInit)
	, packetModel(channelCountInit)
	{
		packetModel.readHeader(srcPacket.read32());
	}

	uint32_t sectionCount()
	{ return packetModel.sectionCount; }

	std::unique_ptr<Section> readSection()
	{
		std::unique_ptr<Section> section(new Section);

		packetModel.getSection(srcPacket, *section);

		packetModel.finishSection(*section);
		return std::move(section);
	}

	Packet& srcPacket;
	PacketModel packetModel;
};

}

#endif // UUID_E6889254702D4480D8712EB9005A536B
